<template>
	<view style="background-color: #17191A; min-height: 100vh;">
		<u-navbar :autoBack="true" left-icon-color="#fff" rightIcon="setting" @rightClick="gorightClick()"
			:bgColor="bgColor" :placeholder="true">
			<view class="navtitle" slot="center">
				{{title||'聊天'}}({{groupnum + 300}})
			</view>
		</u-navbar>
		<view class="tips color_fff size_12" :class="{ 'show':ajax.loading }" @tap="getHistoryMsg">
			{{ajax.loadText}}
		</view>
		<view class="noc-text" v-if="noticeshow == true && group_notice!=''">
			{{group_notice}}
			<view class="close" @click="noclose()">
				<u-icon name="close" color="#ffffff" size="16"></u-icon>
			</view>
		</view>
		<view class="box-1" @click="funshow = false,cuindex=null"
			:style="funshow==true?'padding-bottom: 500rpx;':'padding-bottom: 100rpx;'">
			<view class="talk-list">
				<view v-for="(item,index) in talkList" :key="index" :id="`msg-${item.id}`">
					<view class="talk-time" v-if="item.messageType != 'RC:RcCmd'&&item.messageType != 'RC:envelopelq'&&item.messageType != 'RC:adduser'">
						{{ $util.timeChange(item.sentTime)}}
					</view>
					<view class="item flex_col" :class="item.type == 1 ? 'push':'pull'"
						v-if="item.messageType != 'RC:RcCmd'&&item.messageType != 'RC:envelopelq'&&item.messageType != 'RC:adduser'">
						<!-- @click="goinfo(item)" -->
						<u--image :showLoading="true" style="border-radius: 20rpx;overflow: hidden;" :src="item.pic"
							loadingIcon="/static/chat/logo.png" errorIcon="/static/chat/logo.png" width="55px"
							height="55px"></u--image>
						<view style="position: relative;">
							<view class="item-name" v-if="item.type == 0">{{item.name}}</view>
							<view class="content" v-if="item.messageType == 'RC:TxtMsg'"
								@longtap="handleLongPress(index)">{{item.content}}</view>
							<view class="content" v-if="item.messageType == 'RC:ImgMsg'"
								@longtap="handleLongPress(index)">
								<image style="width: 100px; height: 100px;" @click="goview(item.image)"
									:src="'data:image\/(jpeg|png|jpg);base64,'+item.content" mode="widthFix"></image>
							</view>
							<view class="content-vcmsg" hover-class="contentType2-hover-class"
								:class="[{ 'content-type-right': item.type }]" v-if="item.messageType == 'RC:VcMsg'"
								@longtap="handleLongPress(index)">
								<view class="voice_icon" @tap="handleAudio(index)" :class="[
										{ voice_icon_right: item.type },
										{ voice_icon_left: !item.type },
										{ voice_icon_right_an:item.anmitionPlay && item.type },
										{ voice_icon_left_an:item.anmitionPlay &&!item.type }
									]"></view>
								<view class="voice_text" @tap="handleAudio(index)">{{ item.content.duration }}''</view>
							</view>
							<view class="content-hb" @click="goopenhb(item)" v-if="item.messageType == 'RC:envelope'">
								<image class="hb-box" src="/static/chat/hb.png" mode=""></image>
							</view>
							<view v-show="cuindex == index" :class="item.type == 1 ? 'fun-data1':'fun-data2'">
								<view class="fun-item" v-if="item.messageType == 'RC:TxtMsg'"
									@tap.stop="gocory(item.content)">
									<u-icon name="order" color="#000000" size="16"></u-icon>
									<view>复制</view>
								</view>
								<view class="fun-item" v-if="item.type == 1"
									@tap.stop="gowithdraw(item.uid,item.sentTime)">
									<u-icon name="reload" color="#000000" size="16"></u-icon>
									<view>撤回</view>
								</view>
								<view class="fun-item" @tap.stop="godelete(item.uid,item.sentTime,item.type)">
									<u-icon name="trash" color="#000000" size="16"></u-icon>
									<view>删除</view>
								</view>
							</view>
						</view>
					</view>
					<view v-else-if="item.messageType == 'RC:envelopelq'" class="envelopelq">
						<text>{{item.name}}领取了红包</text>
					</view>
					<view v-else-if="item.messageType == 'RC:adduser'" class="withdraw">
						<text>{{item.name}}加入了群聊</text>
					</view>
					<view v-else class="withdraw">
						<text v-if="item.type == 1">你撤回了一条消息</text>
						<text v-else>对方撤回了一条消息</text>
					</view>
				</view>
			</view>
		</view>

		<view class="box-2">
			<view class="fun-btn">
				<view class="btn-left">
					<view class="middbox">
						<view class="yuyin">
							<image class="img1" v-if="yuyinshow == true" src="/static/chat/fun3.png"
								@click="yuyinshow = false,funshow = false" mode=""></image>
							<image class="img2" v-else src="/static/chat/fun4.png" mode=""
								@click="yuyinshow = true,funshow = false"></image>
						</view>
						<view class="midd" v-if="yuyinshow == true">
							<u--input placeholder="请输入聊天内容" @focus="funshow = false" @input="input" color="#fff"
								@confirm="send" shape="circle"
								customStyle="background-color: #232526; padding: 15rpx 30rpx;" border="none"
								v-model="content"></u--input>
						</view>
						<view class="midd" v-else>
							<view class="voice_title" :style="{ opacity: recording ? '0.8' : '1' }"
								@touchstart.stop.prevent="startVoice" @touchend.stop="endVoice"
								@touchmove.stop.prevent="moveVoice">
								{{ voiceTitle }}
							</view>
						</view>
					</view>
				</view>
				<view class="btn-right">
					<image src="/static/chat/fun5.png" @click="goopen(1)" mode=""></image>
					<image src="/static/chat/fun6.png" @click="goopen(2)" v-if="isshow == true" mode=""></image>
					<u-button color="#5FBC94" class="send" v-else text="发送" @click="send"></u-button>
				</view>
			</view>
			<view class="fun-box" v-show="funshow">
				<view class="emoji-div" v-show="navshow==1">
					<view class="emoji-item" v-for="(item,index) in emojiList" :key="index+'emo'"
						@click="changeEmoji(index)">
						{{item}}
					</view>
				</view>
				<view class="img-box" v-show="navshow==2">
					<view class="img-item" @click="goimg('album')">
						<view class="icon"><u-icon name="photo" color="#ffffff" size="50"></u-icon></view>
						<text>图片</text>
					</view>
					<view class="img-item" @click="goimg('camera')">
						<view class="icon"><u-icon name="camera" color="#ffffff" size="50"></u-icon></view>
						<text>相机</text>
					</view>
					<view class="img-item" @click="goqiandao" v-if="is_hman == true">
						<view class="icon">
							<u-icon name="red-packet" color="#ffffff" size="50"></u-icon>
						</view>
						<text>红包</text>
					</view>
				</view>
			</view>
		</view>
		<!-- //语音动画 -->
		<view class="voice_an" v-if="recording">
			<view class="voice_an_icon">
				<view id="one" class="wave"></view>
				<view id="two" class="wave"></view>
				<view id="three" class="wave"></view>
				<view id="four" class="wave"></view>
				<view id="five" class="wave"></view>
				<view id="six" class="wave"></view>
				<view id="seven" class="wave"></view>
			</view>
			<view class="text">{{voiceIconText}}</view>
		</view>
		<u-popup :show="show" @close="close" mode="center" bgColor="transparent">
			<view class="input-box">
				<view class="title">发送红包</view>
				<u--input placeholder="红包总金额" customStyle="background-color: #424242; padding: 20rpx; width:450rpx;"
					prefixIconStyle="color: #fff;" type="number" :maxlength="5" color="#fff" border="none"
					v-model="total_amount"></u--input>
				<u--input placeholder="红包总数量"
					customStyle="background-color: #424242; padding: 20rpx; width:450rpx;margin-top: 20rpx;"
					prefixIconStyle="color: #fff;" type="number" :maxlength="4" color="#fff" border="none"
					v-model="totalNum"></u--input>
				<view class="btn">
					<u-button type="primary" color="#5FBC94" @click="gobuy()" text="确定"></u-button>
				</view>
			</view>
		</u-popup>
		<u-overlay :show="hbshow">
			<view class="flex-open">
				<view class="head-box">
					<image :src="hbitem.pic" mode=""></image>
					<view>{{hbitem.name}}发出的红包</view>
				</view>
				<view class="text" v-if="quantity == true">恭喜发财，大吉大利</view>
				<view class="text2" v-else>手慢了,红包派完了</view>
				<view class="open" v-if="quantity == true" @click.stop="goopenurl(hbitem)"
					:class="isadin ==1?'ani1':'ani2'">
					開
				</view>
				<view class="tisp" @click="goeye(hbitem)">
					<view>
						看看大家的手气
					</view>
					<u-icon name="arrow-right" color="#EBCD9A" size="16"></u-icon>
				</view>
				<view class="close" @click="hbclose()">
					<u-icon name="close" color="#EBCD9A" size="24"></u-icon>
				</view>
			</view>
		</u-overlay>
	</view>
</template>

<script>
	import {
		emoji
	} from '@/common/emoji'
	export default {
		data() {
			return {
				bgColor: '#17191A',
				talkList: [],
				hbshow: false,
				ajax: {
					rows: 20, //每页数量
					page: 1, //页码
					flag: true, // 请求开关
					loading: true, // 加载中
					time: 0,
					loadText: '正在获取消息'
				},
				total_amount: '',
				totalNum: '',
				emojiList: emoji,
				content: '',
				isadin: 1,
				id: '',
				title: '',
				noticeshow: true,
				userinfo: {},
				hisinfo: {},
				funshow: false,
				isshow: true,
				navshow: 1,
				imageBase64: '',
				cuindex: null,
				groupnum: 0,
				is_hman: false,
				show: false,
				hbitem: {},
				quantity: true,
				group_notice: '',
				yuyinshow: true,
				voiceIconText: "正在录音...",
				voiceTitle: '按住 说话',
				recording: false,
				PointY: 0,
				canSend: true,
				voiceInterval: null,
				voiceTime: 0,
				voicePath: '',
				mediaRecorder: null,
				recordedChunks: [],
				audioContext: null,
				currentPlayingIndex: null, // 当前播放的音频索引
				stream: null
			}
		},
		onLoad(e) {
			this.id = e.groupid
			this.title = e.name
			this.getHistoryMsg(1);
			// 获取自己的信息
			this.userinfo = uni.getStorageSync('info');
			console.log(this.userinfo)
			if (this.userinfo.u_img == '') {
				this.postuserinfo()
			}
			// 获取群聊信息
			this.posthisinfo()
			// 监听消息
			const Events = this.$RongIMLib.Events
			this.$RongIMLib.addEventListener(Events.MESSAGES, this.listener)
		},
		onPageScroll(e) {
			if (e.scrollTop < 5) {
				this.getHistoryMsg(2);
			}
		},
		onShow() {
			this.getuserinfo()
			this.getmedio()
			this.ajax.flag = true
			this.ajax.loading = true;
			this.getHistoryMsg(1);
		},
		onHide(){
			// if (this.currentPlayingIndex !== null) {
			// 	this.talkList[this.currentPlayingIndex].anmitionPlay = false
			// }
			// 清除未读
			this.clearunread()
			// 销毁音频
			this.destroyAudioContext();
			//移除消息监听
			const Events = this.$RongIMLib.Events
			this.$RongIMLib.removeEventListener(Events.MESSAGES, this.listener)
		},
		onUnload() {
			// 清除未读
			this.clearunread()
			// 销毁音频
			this.destroyAudioContext();
			//移除消息监听
			const Events = this.$RongIMLib.Events
			this.$RongIMLib.removeEventListener(Events.MESSAGES, this.listener)
		},
		methods: {
			postuserinfo() {
				let params = {

				}
				this.$Request({
					method: 'POST',
					url: '/api/Personal/myIndex',
					data: params
				}).then(res => {
					if (res.code == 1) {
						this.userinfo.u_img = res.data.user.u_img.replace(/https?:\/\/web\.sunsk\.top/, '')
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
			},
			initAudio(index) {
				// 如果已有音频上下文，销毁并重建
				if (this.audioContext) {
					this.audioContext.destroy();
				}

				// 创建新的音频上下文
				this.audioContext = uni.createInnerAudioContext();
				this.audioContext.src = this.talkList[index].content.content;
				this.audioContext.autoplay = false;
				this.audioContext.onError((res) => {
					console.error('音频播放错误：', res);
				});

				// 监听播放结束事件
				this.audioContext.onEnded(() => {
					this.handleAudioEnd(index);
				});
			},
			handleAudio(index) {
				const item = this.talkList[index];

				// 暂停当前播放的音频
				if (this.currentPlayingIndex !== null && this.currentPlayingIndex !== index) {
					// 停止上一个播放的音频
					if (this.audioContext) {
						this.audioContext.stop();
					}
					this.talkList[this.currentPlayingIndex].anmitionPlay = false;
				}

				if (!this.audioContext || this.audioContext.src !== this.talkList[index].content.content) {
					this.initAudio(index);
				}

				if (!item.anmitionPlay) {
					// 播放音频
					this.audioContext.play();
					item.anmitionPlay = true;
					this.currentPlayingIndex = index;
				} else {
					// 暂停音频
					this.audioContext.pause();
					item.anmitionPlay = false;
					this.currentPlayingIndex = null;
				}
			},
			handleAudioEnd(index) {
				// 停止动画
				if (this.currentPlayingIndex === index) {
					this.talkList[index].anmitionPlay = false;
					this.currentPlayingIndex = null;
				}
			},
			destroyAudioContext() {
				this.stream.getTracks().forEach(track => track.stop());
				this.stream = null;
				this.audioContext = null;
				this.mediaRecorder = null;
				this.recordedChunks = []

			},
			getmedio() {
				navigator.mediaDevices.getUserMedia({
						audio: true
					})
					.then(stream => {
						this.stream = stream;
						this.mediaRecorder = new MediaRecorder(stream);
						this.mediaRecorder.ondataavailable = event => {
							if (event.data.size > 0) {
								this.recordedChunks.push(event.data);
							}
						};
					})
					.catch(err => {
						console.error('Error accessing audio media:', err);
					});
			},
			//录音已经开始
			beginVoice() {
				this.voiceTitle = '松开 结束'
				this.voiceInterval = setInterval(() => {
					this.voiceTime++;
				}, 1000)
			},
			//move 正在录音中
			moveVoice(e) {
				const PointY = e.touches[0].clientY
				const slideY = this.PointY - PointY;
				if (slideY > uni.upx2px(120)) {
					this.canSend = false;
					this.voiceIconText = '松开手指 取消发送 '
				} else if (slideY > uni.upx2px(60)) {
					this.canSend = true;
					this.voiceIconText = '手指上滑 取消发送 '
				} else {
					this.voiceIconText = '正在录音... '
				}
			},
			//准备开始录音
			startVoice(e) {
				this.recording = true;
				this.canSend = true;
				this.voiceIconText = "正在录音..."
				this.mediaRecorder.start();
				this.PointY = e.touches[0].clientY;
				this.beginVoice();
			},
			//结束录音
			endVoice() {
				this.mediaRecorder.stop();
				this.recording = false;
				this.voiceTitle = '按住 说话'
				if (this.canSend == false) {
					this.voiceTime = 0
					clearInterval(this.voiceInterval);
					this.voicePath = '';
					this.mediaRecorder.stop();
					this.mediaRecorder = null;
					this.recordedChunks = [];
					this.getmedio()
				} else {
					if (this.voiceTime < 1) {
						uni.showToast({
							title: '说话时间过短！',
							icon: 'error'
						})
						this.voiceTime = 0
						clearInterval(this.voiceInterval);
						this.voicePath = '';
						this.mediaRecorder.stop();
						this.mediaRecorder = null;
						this.recordedChunks = [];
						this.getmedio()
						return
					}
					if (this.voiceTime > 58) {
						uni.showToast({
							title: '说话时间请控制在60秒以内！',
							icon: 'error'
						})
						this.voiceTime = 0
						clearInterval(this.voiceInterval);
						this.voicePath = '';
						this.mediaRecorder.stop();
						this.mediaRecorder = null;
						this.recordedChunks = [];
						this.getmedio()
						return
					}
					this.mediaRecorder.onstop = () => {
						const blob = new Blob(this.recordedChunks, {
							type: 'audio/wav'
						});
						this.voicePath = URL.createObjectURL(blob);
						this.recordedChunks = []; // Clear the chunks for next recording
						console.log(this.voicePath, this.voiceTime);
						this.onUpload(this.voicePath, this.voiceTime);
					};
				}


			},
			onUpload(e, i) {
				console.log(e, i)
				uni.showLoading({
					mask: true
				})
				let app = this
				uni.uploadFile({
					url: '/api/rong/receiveVoice', //后端接口url
					filePath: e,
					header: {
						'Access-Control-Allow-Origin': '*',
					},
					data: {
						token: uni.getStorageSync("token") || ''
					},
					name: 'file', //和后端接口需要的参数名一致
					success: (res) => {
						let info = JSON.parse(res.data)
						if(info.code == 1){
							// 定义消息投送目标会话
							const conversation = {
								conversationType: app.$RongIMLib.ConversationType.GROUP,
								targetId: app.id
							}
							const message = new app.$RongIMLib.VoiceMessage({
								content: info.file_path,
								duration: Number(i).toFixed(0), // 需要设置正确的持续时间（可以从服务器获得）
								messageType: 'RC:VcMsg',
								receiveName: app.hisinfo.group_name,
								receivePortraitUri: app.hisinfo.group_img,
								sendName: app.userinfo.user,
								sendPortraitUri: 'https://web.sunsk.top/' + app.userinfo.u_img
							});
							// 配置属性
							const options = {
								// 如果需要发送 @ 消息，isMentioned 需设置为 true
								isMentioned: false,
							}
							app.$RongIMLib.sendMessage(conversation, message, options).then(res => {
								if (res.code === app.$RongIMLib.ErrorCode.SUCCESS) {
									// 消息发送成功，可以根据返回结果中的 messageId 字段将列表中的该消息状态改为发送成功。
									console.log('消息发送成功', res.data)
									app.talkList.push({
										name: app.userinfo.user,
										sentTime: res.data.sentTime,
										messageType: 'RC:VcMsg',
										id: res.data.messageId, 
										uid: res.data.messageUId,
										userid: res.data.senderUserId,
										content: res.data.content,
										type: 1, // 发出去的消息类型
										pic: 'https://web.sunsk.top/' + app.userinfo
											.u_img, // 根据需要设置头像
										file_path: info.file_path,
										duration: Number(i).toFixed(0)
									});
									app.voicePath = '';
									app.mediaRecorder = null;
									app.recordedChunks = [];
									app.voiceTime = 0
									clearInterval(app.voiceInterval);
									app.getmedio()
									app.$nextTick(() => {
										uni.pageScrollTo({
											scrollTop: 9999999999999, // 设置一个超大值，以保证滚动条滚动到底部
											duration: 0
										});
									})
									uni.hideLoading()
								} else {
									uni.hideLoading()
									console.log('消息发送失败', res.code, res.msg)
									app.voicePath = '';
									app.mediaRecorder = null;
									app.recordedChunks = [];
									app.voiceTime = 0
									clearInterval(app.voiceInterval);
									app.getmedio()
									if (res.code == 22408) {
										uni.showToast({
											title: '您已被禁言！',
											icon: 'none'
										})
									} else if (res.code == 22406) {
										uni.showToast({
											title: '您已不是群成员！',
											icon: 'none'
										})
									} else {
										uni.showToast({
											title: '消息发送失败！',
											icon: 'none'
										})
									}
							
								}
							})
						}else{
							uni.hideLoading()
							uni.showToast({
								title: info.msg,
								icon: 'none'
							})
						}
						
					},
					complete: (ok) => {
						uni.hideLoading()
					}
				})

			},
			noclose() {
				this.noticeshow = false
			},
			getuserinfo() {
				this.$Request({
					method: 'POST',
					url: '/api/rong/getGroupInfo',
					data: {
						group_id: this.id,
					}
				}).then(res => {
					if (res.code == 1) {
						console.log(res)
						this.group_notice = res.group_info.group_notice
					}
				})
			},
			hbclose() {
				if (this.isadin == 2) {
					return
				}
				this.hbshow = false
			},
			goopenurl(item) {
				console.log(item)
				if (this.isadin == 2) {
					return
				}
				uni.showLoading({
					mask: true
				})
				let params = {
					redPacketId: item.content.packet_id
				}
				this.$Request({
					method: 'POST',
					url: '/api/luckys/grabRedPacket',
					data: params
				}).then(res => {
					uni.hideLoading()
					if (res.code == 1) {
						this.isadin = 2
						setTimeout(() => {
							this.isadin = 1
							this.hbshow = false
							const PersonMessage = this.$RongIMLib.registerMessageType(
								'RC:envelopelq',
								true, true, [],
								false)
							const message = new PersonMessage({
								sendPortraitUri: 'https://web.sunsk.top' + this.userinfo
									.u_img, // 根据需要设置头像
								sendName: this.userinfo.user,
								receiveName: this.hisinfo.group_name,
								receivePortraitUri: this.hisinfo.group_img,
							})
							this.$RongIMLib.sendMessage({
								conversationType: this.$RongIMLib.ConversationType.GROUP,
								targetId: this.id
							}, message).then(res1 => {
								if (res1.code == 0) {
									console.log(res1.code)
									this.talkList.push({
										"messageType": 'RC:envelopelq',
										"type": 1,
										"name": this.userinfo.user
									})
									this.$nextTick(() => {
										uni.pageScrollTo({
											scrollTop: 9999999999999, // 设置一个超大值，以保证滚动条滚动到底部
											duration: 0
										});
									})
									uni.navigateTo({
										url: '/pages/chat/grouphb/index?item=' +
											encodeURIComponent(JSON.stringify(
												item))
									})
								} else {
									console.log(res1.code)
								}
							})
						}, 1500)
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})

			},
			goeye(item) {
				uni.navigateTo({
					url: '/pages/chat/grouphb/index?item=' +
						encodeURIComponent(JSON.stringify(item))
				})
			},
			goopenhb(item) {
				console.log(item)
				uni.showLoading({
					mask: true
				})
				let params = {
					redPacketId: item.content.packet_id
				}
				this.$Request({
					method: 'POST',
					url: '/api/luckys/statusRedPacket',
					data: params
				}).then(res => {
					uni.hideLoading()
					if (res.code == 1) {
						if (res.status == 0) {
							this.quantity = true
							uni.navigateTo({
								url: '/pages/chat/grouphb/index?item=' + encodeURIComponent(JSON
									.stringify(item))
							})
						} else {
							if (res.remaining_quantity == 0) {
								this.quantity = false
								this.hbshow = true
								this.hbitem = item
							} else {
								this.quantity = true
								this.hbshow = true
								this.hbitem = item
							}
						}
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
				// this.hbshow = true
				// this.hbitem = item
			},
			gobuy() {
				if (this.total_amount == '') {
					uni.showToast({
						title: '红包总金额不能为空！',
						icon: 'none'
					})
				}
				if (this.totalNum == '') {
					uni.showToast({
						title: '红包总数量不能为空！',
						icon: 'none'
					})
				}
				uni.showLoading({
					mask: true
				})
				let params = {
					total_amount: this.total_amount,
					totalNum: this.totalNum,
				}
				this.$Request({
					method: 'POST',
					url: '/api/luckys/sendred',
					data: params
				}).then(res => {
					if (res.code == 1) {
						console.log(res)
						const PersonMessage = this.$RongIMLib.registerMessageType('RC:envelope', true,
							true, [],
							false)
						const message = new PersonMessage({
							total_amount: this.total_amount,
							totalNum: this.totalNum,
							sendPortraitUri: 'https://web.sunsk.top' + this.userinfo
								.u_img, // 根据需要设置头像
							sendName: this.userinfo.user,
							receiveName: this.hisinfo.group_name,
							receivePortraitUri: this.hisinfo.group_img,
							packet_id: res.packet_id,
							anmitionPlay: false
						})
						this.$RongIMLib.sendMessage({
							conversationType: this.$RongIMLib.ConversationType.GROUP,
							targetId: this.id
						}, message).then(res1 => {
							if (res1.code === 0) {
								console.log(res1)
								this.talkList.push({
									messageType: 'RC:envelope',
									type: 1, // 发出去的消息类型
									pic: 'https://web.sunsk.top/' + this.userinfo
										.u_img, // 根据需要设置头像
									name: this.userinfo.user,
									sentTime: res1.data.sentTime,
									content: res1.data.content,
									anmitionPlay: false
								});
								uni.showToast({
									title: '发送成功！',
									icon: 'none'
								})
								this.funshow = false
								this.show = false
								this.$nextTick(() => {
									uni.pageScrollTo({
										scrollTop: 9999999999999, // 设置一个超大值，以保证滚动条滚动到底部
										duration: 0
									});
								})
							} else {
								console.log(res.code)
							}
						})
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
			},
			close() {
				this.show = false
			},
			goqiandao() {
				this.show = true
			},
			goinfo(item) {
				if (item.userid == this.userinfo.member_id) {
					return
				}
				uni.navigateTo({
					url: '/pages/chat/userprofile/index?id=' + item.userid + '&type=group'
				})
			},
			gorightClick() {
				uni.navigateTo({
					url: '/pages/chat/groupporfile/index?id=' + this.id
				})
			},
			gowithdraw(uid, sentTime) {
				this.cuindex = null;
				const conversation = {
					targetId: this.id,
					conversationType: this.$RongIMLib.ConversationType.GROUP
				};
				const options = {
					messageUId: uid,
					sentTime: sentTime,
					user: {
						name: this.hisinfo.group_name,
						portraitUri: this.hisinfo.group_img
					}
				};
				this.$RongIMLib.recallMessage(conversation, options).then((msg) => {
					if (msg.code == 0) {
						console.log('撤回成功！', msg);
						uni.showToast({
							title: '撤回成功！',
							icon: 'none'
						});
						let index = this.talkList.findIndex(i => i.uid == uid)
						if (index != -1) {
							this.talkList.splice(index, 1)
							this.talkList.push({
								"messageType": 'RC:RcCmd',
								"type": 1
							})
							this.$nextTick(() => {
								uni.pageScrollTo({
									scrollTop: 9999999999999, // 设置一个超大值，以保证滚动条滚动到底部
									duration: 0
								});
							})
						}

					} else {
						uni.showToast({
							title: '撤回失败！',
							icon: 'none'
						});
					}
				})
			},
			godelete(uid, sentTime, type) {
				const app = this;
				app.cuindex = null;
				uni.showModal({
					title: '提示',
					content: '是否删除此消息！',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							const conversation = {
								targetId: app.id,
								conversationType: app.$RongIMLib.ConversationType.GROUP
							};
							const messages = [{
								messageUId: uid,
								sentTime: sentTime,
								messageDirection: type
							}];
							app.$RongIMLib.deleteMessages(conversation, messages).then((msg) => {
								if (msg.code == 0) {
									console.log('删除消息成功', msg);
									uni.showToast({
										title: '删除成功！',
										icon: 'none'
									});
									let index = app.talkList.findIndex(i => i.uid == uid)
									if (index != -1) {
										app.talkList.splice(index, 1)
									}
								} else {
									uni.showToast({
										title: '删除失败！',
										icon: 'none'
									});
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			gocory(e) {
				let app = this
				uni.setClipboardData({
					data: e,
					success: () => {
						uni.showToast({
							title: '复制成功',
							icon: 'none'
						});
						app.cuindex = null
					},
					fail: (error) => {
						uni.showToast({
							title: '复制失败',
							icon: 'none'
						});
						app.cuindex = null
					}
				});
			},
			handleLongPress(e) {
				console.log(e)
				this.cuindex = e
			},
			goview(img) {
				console.log(img)
				let arr = []
				arr.push(img)
				uni.previewImage({
					urls: arr,
					longPressActions: {
						success: function(data) {
							console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) +
								'张图片');
						},
						fail: function(err) {
							console.log(err.errMsg);
						}
					}
				});
			},
			goimg(type) {
				let app = this
				uni.chooseImage({
					count: 1,
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: [type], //从相册选择
					success: function(res) {
						console.log(res)
						console.log(JSON.stringify(res.tempFilePaths));
						//获得选择好的文件,就算只有一个文件也是数组
						const tempFilePaths = res.tempFilePaths;
						app.$util.picture(res).then(base64img => {
							console.log('压缩后的base64图片:', base64img);
							app.imageBase64 = base64img.replace(
								/^data:image\/(jpeg|png|jpg);base64,/,
								'');
						}).catch(err => {
							console.error('图片处理出错:', err);
						});
						uni.showLoading({
							mask: true
						})
						uni.uploadFile({
							url: '/api/upload/upload', //后端接口url
							filePath: tempFilePaths[0],
							header: {
								'Access-Control-Allow-Origin': '*',
							},
							data: {
								token: uni.getStorageSync("token") || ''
							},
							name: 'file', //和后端接口需要的参数名一致
							success: async (res1) => {
								let img = 'https://web.sunsk.top' + JSON.parse(res1.data)
									.url;
								let info = {
									Image: img,
									base64: app.imageBase64
								};
								if (app.imageBase64.length > 10240) {
									uni.showToast({
										title: '图片质量过大,发送失败！',
										icon: 'none'
									})
									return
								} else {
									app.sendimage(info)
								}
								uni.hideLoading();
							},
							complete: (ok) => {
								uni.hideLoading()
							}
						})
					}
				});
			},
			changeEmoji(index) {
				this.content += this.emojiList[index]
			},
			goopen(num) {
				this.navshow = num
				this.funshow = true
				this.yuyinshow = true
				this.$nextTick(() => {
					uni.pageScrollTo({
						scrollTop: 9999999999999, // 设置一个超大值，以保证滚动条滚动到底部
						duration: 0
					});
				})
			},
			input(e) {
				if (e == '') {
					this.isshow = true
				} else {
					this.isshow = false
				}
			},
			clearunread() {
				const conversationType = this.$RongIMLib.ConversationType.GROUP;
				const targetId = this.id;
				this.$RongIMLib.clearMessagesUnreadStatus({
					conversationType,
					targetId
				}).then(res => {
					if (res.code === 0) {
						console.log(res.code)
					} else {
						console.log(res.code, res.msg)
					}
				})
			},
			listener(evt) {
				console.log('来消息啦！', evt)
				if (this.userinfo.member_id != evt.messages[0].senderUserId) {
					if (evt.messages[0].messageType == 'RC:RcCmd') {
						let info = {
							messageType: evt.messages[0].messageType,
							type: this.userinfo.member_id != evt.messages[0].senderUserId ? 0 : 1,
						}
						let index = this.talkList.findIndex(i => i.sentTime == evt.messages[0].content.sentTime)
						if (index != -1) {
							this.talkList.splice(index, 1)
						}
						this.ajax.loading = true;
						setTimeout(() => {
							this.hideLoadTips(true);
							this.talkList.push(info);
							this.$nextTick(() => {
								uni.pageScrollTo({
									scrollTop: 9999999999999, // 设置一个超大值，以保证滚动条滚动到底部
									duration: 0
								});
							})
						}, 300)
					} else if (evt.messages[0].messageType == 'RC:envelopelq') {
						let info = {
							messageType: evt.messages[0].messageType,
							type: 1,
							name: evt.messages[0].content.sendName,
						}
						this.ajax.loading = true;
						setTimeout(() => {
							this.hideLoadTips(true);
							this.talkList.push(info);
							this.$nextTick(() => {
								uni.pageScrollTo({
									scrollTop: 9999999999999, // 设置一个超大值，以保证滚动条滚动到底部
									duration: 0
								});
							})
						}, 300)
					} else  if (evt.messages[0].messageType == 'RC:adduser') {
						let info = {
							name: evt.messages[0].content.addname,
						}
						this.ajax.loading = true;
						setTimeout(() => {
							this.hideLoadTips(true);
							this.talkList.push(info);
							this.$nextTick(() => {
								uni.pageScrollTo({
									scrollTop: 9999999999999, // 设置一个超大值，以保证滚动条滚动到底部
									duration: 0
								});
							})
						}, 300)
					} else if (evt.messages[0].messageType == 'RC:envelope') {
						let info = {
							name: evt.messages[0].content.sendName,
							sentTime: evt.messages[0].sentTime,
							image: evt.messages[0].content.imageUri || '',
							messageType: evt.messages[0].messageType,
							id: evt.messages[0].messageId,
							uid: evt.messages[0].messageUId,
							content: evt.messages[0].content,
							userid: evt.messages[0].senderUserId,
							type: this.userinfo.member_id != evt.messages[0].senderUserId ? 0 : 1,
							pic: evt.messages[0].content.sendPortraitUri
						}
						this.ajax.loading = true;
						setTimeout(() => {
							this.hideLoadTips(true);
							this.talkList.push(info);
							this.$nextTick(() => {
								uni.pageScrollTo({
									scrollTop: 9999999999999, // 设置一个超大值，以保证滚动条滚动到底部
									duration: 0
								});
							})
						}, 300)
					} else if (evt.messages[0].messageType == 'RC:VcMsg') {
						let info = {
							name: evt.messages[0].content.sendName,
							sentTime: evt.messages[0].sentTime,
							image: evt.messages[0].content.imageUri || '',
							messageType: evt.messages[0].messageType,
							id: evt.messages[0].messageId,
							uid: evt.messages[0].messageUId,
							content: evt.messages[0].content,
							userid: evt.messages[0].senderUserId,
							type: this.userinfo.member_id != evt.messages[0].senderUserId ? 0 : 1,
							pic: evt.messages[0].content.sendPortraitUri,
							anmitionPlay: false
						}
						this.ajax.loading = true;
						setTimeout(() => {
							this.hideLoadTips(true);
							this.talkList.push(info);
							this.$nextTick(() => {
								uni.pageScrollTo({
									scrollTop: 9999999999999, // 设置一个超大值，以保证滚动条滚动到底部
									duration: 0
								});
							})
						}, 300)
					} else {
						let info = {
							name: evt.messages[0].content.sendName,
							sentTime: evt.messages[0].sentTime,
							image: evt.messages[0].content.imageUri || '',
							messageType: evt.messages[0].messageType,
							id: evt.messages[0].messageId,
							uid: evt.messages[0].messageUId,
							content: evt.messages[0].content.content,
							userid: evt.messages[0].senderUserId,
							type: this.userinfo.member_id != evt.messages[0].senderUserId ? 0 : 1,
							pic: evt.messages[0].content.sendPortraitUri
						}
						this.ajax.loading = true;
						setTimeout(() => {
							this.hideLoadTips(true);
							this.talkList.push(info);
							this.$nextTick(() => {
								uni.pageScrollTo({
									scrollTop: 9999999999999, // 设置一个超大值，以保证滚动条滚动到底部
									duration: 0
								});
							})
						}, 300)
					}
				}
			},
			posthisinfo() {
				this.$Request({
					method: 'POST',
					url: '/api/rong/getGroupInfo',
					data: {
						group_id: this.id,
					}
				}).then(res => {
					if (res.code == 1) {
						console.log(res)
						this.groupnum = res.data.length
						this.hisinfo = res.group_info
						res.data.map(item => {
							if (item.is_hman == 1) {
								if (item.id == this.userinfo.member_id) {
									this.is_hman = true
								} else {
									this.is_hman = false
								}
							}
						})
						if (this.groupnum < 1) {
							const conversationType = this.$RongIMLib.ConversationType.GROUP;
							const targetId = this.id;
							this.$RongIMLib.removeConversation({
								conversationType,
								targetId: targetId,
							}).then(res => {
								// 删除指定会话成功
								if (res.code === 0) {
									console.log(res.code)
									uni.showToast({
										title: '此群以解散！',
										icon: 'none'
									})
									setTimeout(() => {
										uni.switchTab({
											url: '/pages/chat/index'
										})
									}, 1000)
								} else {
									console.log(res.code, res.msg)
								}
							})
						}
					}
				})
			},
			// 获取历史消息
			getHistoryMsg(type) {
				if (!this.ajax.flag) {
					return; //
				}
				// 此处用到 ES7 的 async/await 知识，为使代码更加优美。不懂的请自行学习。
				let get = async () => {
					this.hideLoadTips();
					this.ajax.flag = false;
					let data = await this.joinHistoryMsg();
					if (data.length < 1) {
						// 第一页，则取当前消息数据的最后一条信息元素
						this.hideLoadTips(true);
						return
					}
					if (this.ajax.page == 1) {
						this.talkList = data
					} else {
						// 将获取到的消息数据合并到消息数组中
						this.talkList = [...data, ...this.talkList];
					}

					// 数据挂载后执行，不懂的请自行阅读 Vue.js 文档对 Vue.nextTick 函数说明。
					this.$nextTick(() => {
						// 设置当前滚动的位置
						if (type == 1) {
							this.setPageScrollTo();
						}

						this.hideLoadTips(true);

						if (data.length < this.ajax.rows) {
							// 当前消息数据条数小于请求要求条数时，则无更多消息，不再允许请求。
							// 可在此处编写无更多消息数据时的逻辑
						} else {
							this.ajax.page++;
							// 延迟 200ms ，以保证设置窗口滚动已完成
							setTimeout(() => {
								this.ajax.flag = true;
							}, 200)
						}

					})
				}
				get();
			},
			// 拼接历史记录消息，正式项目可替换为请求历史记录接口
			joinHistoryMsg() {
				// 此处用到 ES6 的 Promise 知识，不懂的请自行学习。
				return new Promise((done, fail) => {
					const conversation = {
						targetId: this.id,
						conversationType: this.$RongIMLib.ConversationType.GROUP
					};
					const option = {
						// 获取历史消息的时间戳，默认为 0，表示从当前时间获取
						timestamp: this.ajax.time,
						// 获取条数，有效值 1-100，默认为 20
						count: 20,
						// 值为 0 或 1。0 表示降序
						order: 0
					};
					if (this.ajax.page == 1) {
						option.order = 0
					} else {
						this.ajax.time = Date.now()
						option.order = 1
					}
					this.$RongIMLib.getHistoryMessages(conversation, option).then(result => {
						// 获取到的消息列表
						let data = []
						if (result.data.list.length > 0) {
							result.data.list.map((item) => {
								if (item.messageType == 'RC:RcCmd') {
									data.push({
										"sentTime": item.sentTime,
										"messageType": item.messageType,
										"type": this.userinfo.member_id != item
											.senderUserId ? 0 :
											1, // 此为消息类别，设 1 为发出去的消息，0 为收到对方的消息,
									})
								} else if (item.messageType == 'RC:envelopelq') {
									data.push({
										"sentTime": item.sentTime,
										"messageType": item.messageType,
										"type": this.userinfo.member_id != item
											.senderUserId ? 0 :
											1, // 此为消息类别，设 1 为发出去的消息，0 为收到对方的消息,
										'name': item.content.sendName,
									})
								} else if (item.messageType == 'RC:adduser') {
									data.push({
										"sentTime": item.sentTime,
										"messageType": item.messageType,
										"type": this.userinfo.member_id != item
											.senderUserId ? 0 :
											1, // 此为消息类别，设 1 为发出去的消息，0 为收到对方的消息,
										'name': item.content.addname,
									})
								} else  if (item.messageType == 'RC:envelope') {
									data.push({
										'name': item.content.sendName,
										"sentTime": item.sentTime,
										"messageType": item.messageType,
										"id": item.messageId, // 消息的ID
										"uid": item.messageUId,
										"userid": item.senderUserId,
										"content": item.content, // 消息内容
										"type": this.userinfo.member_id != item
											.senderUserId ? 0 :
											1, // 此为消息类别，设 1 为发出去的消息，0 为收到对方的消息,
										"pic": item.content.sendPortraitUri
									})

								} else if (item.messageType == 'RC:VcMsg') {
									data.push({
										'name': item.content.sendName,
										"sentTime": item.sentTime,
										"messageType": item.messageType,
										"id": item.messageId, // 消息的ID
										"uid": item.messageUId,
										"userid": item.senderUserId,
										"content": item.content, // 消息内容
										"type": this.userinfo.member_id != item
											.senderUserId ? 0 :
											1, // 此为消息类别，设 1 为发出去的消息，0 为收到对方的消息,
										"pic": item.content.sendPortraitUri,
										"anmitionPlay": false
									})

								} else {
									data.push({
										'name': item.content.sendName,
										"sentTime": item.sentTime,
										"image": item.content.imageUri || '',
										"messageType": item.messageType,
										"id": item.messageId, // 消息的ID
										"uid": item.messageUId,
										"userid": item.senderUserId,
										"content": item.content.content, // 消息内容
										"type": this.userinfo.member_id != item
											.senderUserId ? 0 :
											1, // 此为消息类别，设 1 为发出去的消息，0 为收到对方的消息,
										"pic": item.content.sendPortraitUri // 头像
									})
								}
							})
						}
						this.ajax.flag = result.data.hasMore; // 是否还有历史消息可获取
						done(data);
						console.log('获取历史消息成功', result.data.list, result.data.hasMore);
					}).catch(error => {
						console.log('获取历史消息失败', error);
						this.ajax.flag = false
						this.ajax.loading = false
						uni.showToast({
							title: '连接失败！',
							icon: 'none'
						})
					});
				})
			},
			// 设置页面滚动位置
			setPageScrollTo() {
				setTimeout(() => {
					uni.pageScrollTo({
						scrollTop: 9999999999999, // 设置一个超大值，以保证滚动条滚动到底部
						duration: 0
					});
				}, 300)
			},
			// 隐藏加载提示
			hideLoadTips(flag) {
				if (flag) {
					this.ajax.loadText = '消息获取成功';
					setTimeout(() => {
						this.ajax.loading = false;
					}, 300);
				} else {
					this.ajax.loading = true;
					this.ajax.loadText = '正在获取消息';
				}
			},
			sendimage(info) {
				// 定义消息投送目标会话
				const conversation = {
					conversationType: this.$RongIMLib.ConversationType.GROUP,
					targetId: this.id
				}
				// 实例化待发送消息，RongIMLib.TextMessage 为内置文本型消息
				const message = new this.$RongIMLib.ImageMessage({
					// 文本内容
					messageType: 'RC:ImgMsg',
					content: info.base64,
					imageUri: info.Image,
					receiveName: this.hisinfo.group_name,
					receivePortraitUri: this.hisinfo.group_img,
					sendName: this.userinfo.user,
					sendPortraitUri: 'https://web.sunsk.top/' + this.userinfo.u_img
				})
				// 配置属性
				const options = {
					// 如果需要发送 @ 消息，isMentioned 需设置为 true
					isMentioned: false,
				}
				// 发送消息
				this.$RongIMLib.sendMessage(conversation, message, options).then(res => {
					if (res.code === this.$RongIMLib.ErrorCode.SUCCESS) {
						// 消息发送成功，可以根据返回结果中的 messageId 字段将列表中的该消息状态改为发送成功。
						console.log('消息发送成功', res.data)
						this.talkList.push({
							name: this.userinfo.user,
							sentTime: res.data.sentTime,
							messageType: 'RC:ImgMsg',
							image: info.Image,
							id: res.data.messageId,
							uid: res.data.messageUId,
							content: res.data.content.content,
							userid: res.data.senderUserId,
							type: 1, // 发出去的消息类型
							pic: 'https://web.sunsk.top/' + this.userinfo.u_img // 根据需要设置头像
						});
						this.$nextTick(() => {
							uni.pageScrollTo({
								scrollTop: 9999999999999, // 设置一个超大值，以保证滚动条滚动到底部
								duration: 0
							});
						})
					} else {
						console.log('消息发送失败', res.code, res.msg)
						if (res.code == 22408) {
							uni.showToast({
								title: '您已被禁言！',
								icon: 'none'
							})
						} else if (res.code == 22406) {
							uni.showToast({
								title: '您已不是群成员！',
								icon: 'none'
							})
						} else {
							uni.showToast({
								title: '消息发送失败！',
								icon: 'none'
							})
						}
					}
				})
			},
			// 发送信息
			send() {
				if (!this.content) {
					uni.showToast({
						title: '请输入有效的内容',
						icon: 'none'
					})
					return;
				}
				// 定义消息投送目标会话
				const conversation = {
					conversationType: this.$RongIMLib.ConversationType.GROUP,
					targetId: this.id
				}
				// 实例化待发送消息，RongIMLib.TextMessage 为内置文本型消息
				const message = new this.$RongIMLib.TextMessage({
					// 文本内容
					messageType: 'RC:TxtMsg',
					content: this.content,
					receiveName: this.hisinfo.group_name,
					receivePortraitUri: this.hisinfo.group_img,
					sendName: this.userinfo.user,
					sendPortraitUri: 'https://web.sunsk.top/' + this.userinfo.u_img
				})
				// 配置属性
				const options = {
					// 如果需要发送 @ 消息，isMentioned 需设置为 true
					isMentioned: false,
				}
				// 发送消息
				this.$RongIMLib.sendMessage(conversation, message, options).then(res => {
					if (res.code === this.$RongIMLib.ErrorCode.SUCCESS) {
						// 消息发送成功，可以根据返回结果中的 messageId 字段将列表中的该消息状态改为发送成功。
						console.log('消息发送成功', res.data)
						this.talkList.push({
							name: this.userinfo.user,
							sentTime: res.data.sentTime,
							messageType: 'RC:TxtMsg',
							id: res.data.messageId,
							uid: res.data.messageUId,
							userid: res.data.senderUserId,
							content: res.data.content.content,
							type: 1, // 发出去的消息类型
							pic: 'https://web.sunsk.top/' + this.userinfo.u_img // 根据需要设置头像
						});
						this.$nextTick(() => {
							// 清空内容框中的内容
							this.content = '';
							this.isshow = true
							uni.pageScrollTo({
								scrollTop: 9999999999999, // 设置一个超大值，以保证滚动条滚动到底部
								duration: 0
							});
						})
					} else {
						console.log('消息发送失败', res.code, res.msg)
						if (res.code == 22408) {
							uni.showToast({
								title: '您已被禁言！',
								icon: 'none'
							})
						} else if (res.code == 22406) {
							uni.showToast({
								title: '您已不是群成员！',
								icon: 'none'
							})
						} else {
							uni.showToast({
								title: '消息发送失败！',
								icon: 'none'
							})
						}
					}
				})
			}
		}
	}
</script>
<style lang="scss">
	/* 根元素样式 设置页面背景、字体大小、字体颜色，字符间距、长单词换行 */
	page {
		font-size: 28rpx;
		box-sizing: border-box;
		color: #333;
		letter-spacing: 0;
		word-wrap: break-word;

	}

	.uni-audio-default {
		width: 0 !important;
	}

	/* 设置常用元素尺寸规则 */
	view,
	textarea,
	input,
	label,
	form,
	button,
	image {
		box-sizing: border-box;
	}

	/* 按钮样式处理 */
	button {
		font-size: 28rpx;
	}

	/* 取消按钮默认的边框线效果 */
	button:after {
		border: none;
	}

	/* 设置图片默认样式，取消默认尺寸 */
	image {
		display: block;
		height: auto;
		width: auto;
	}

	/* 输入框默认字体大小 */
	textarea,
	input {
		font-size: 28rpx;
	}
</style>
<style lang="scss" scoped>
	.navtitle {
		color: #fff;
	}

	.contentType2-hover-class {
		//语音信息点击
		background-color: rgba(121, 121, 121, 0.2) !important;
	}

	.flex-open {
		width: 554rpx;
		height: 921rpx;
		background-image: url('../../../static/chat/hb-open.png');
		background-repeat: no-repeat;
		background-size: 100% 921rpx;
		margin: 0 auto;
		margin-top: 40%;
		position: relative;

		.close {
			position: absolute;
			right: 20rpx;
			top: 20rpx;
		}

		.open {
			width: 176rpx;
			height: 176rpx;
			background: #EBCD9A;
			border-radius: 100%;
			text-align: center;
			line-height: 176rpx;
			margin: 0 auto;
			margin-top: 42%;
			font-size: 52rpx;
		}

		.ani1 {
			animation: resize 1.5s infinite;
		}

		.ani2 {
			animation: vortexout 1.5s infinite;
		}

		@keyframes vortexout {
			0% {
				animation-timing-function: cubic-bezier(0.3, 0, 1, 0.7);
				transform: rotate(0) scale(1);
				opacity: 1
			}

			100% {
				transform: rotate(-1800deg) scale(3);
				opacity: 0
			}
		}

		@keyframes resize {
			0% {
				transform: scale(1);
			}

			50% {
				transform: scale(1.1);
			}

			100% {
				transform: scale(1);
			}
		}

		.tisp {
			color: #EBCD9A;
			display: flex;
			align-items: center;
			justify-content: center;
			margin-top: 16rpx;
			position: absolute;
			bottom: 40rpx;
			left: 0;
			right: 0;
			margin: auto;
			font-size: 26rpx;
		}

		.head-box {
			display: flex;
			align-items: center;
			justify-content: center;
			color: #EBCD9A;
			font-size: 32rpx;
			margin-top: 260rpx;

			image {
				width: 48rpx;
				height: 48rpx;
				margin-right: 10rpx;
			}
		}

		.text {
			text-align: center;
			font-size: 42rpx;
			color: #EBCD9A;
			margin-top: 24rpx;
		}

		.text2 {
			text-align: center;
			font-size: 42rpx;
			color: #EBCD9A;
			margin-top: 24rpx;
		}
	}

	.input-box {
		background-color: #232526;
		padding: 30rpx;
		color: #fff;
		border-radius: 20rpx;

		.title {
			padding-bottom: 30rpx;
			text-align: center;
		}

		.btn {
			margin-top: 30rpx;
		}
	}

	.flex_col {
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		justify-content: flex-start;
		align-items: center;
		align-content: center;
	}

	.color_fff {
		color: #fff;
	}

	.size_12 {
		font-size: 24rpx;
	}

	/* 遮罩 */
	.shade {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		background-color: rgba(0, 0, 0, 0.8);
		z-index: 100;
	}

	/* 弹窗 */
	.shade_box {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		margin: auto;
		z-index: 101;
		min-width: 200rpx;
		min-height: 200rpx;
	}

	/* 加载数据提示 */
	.tips {
		position: fixed;
		left: 0;
		top: 88rpx;
		width: 100%;
		z-index: 9;
		background-color: rgba(0, 0, 0, 0.15);
		height: 72rpx;
		line-height: 72rpx;
		transform: translateY(-80rpx);
		transition: transform 0.3s ease-in-out 0s;
		text-align: center;

		&.show {
			transform: translateY(0);
		}
	}

	.noc-text {
		width: 100%;
		padding: 40rpx 30rpx 30rpx 30rpx;
		background-color: #1D2123;
		border-radius: 20rpx;
		position: fixed;
		top: 80rpx;
		left: 0;
		z-index: 8;
		color: #fff;

		.close {
			position: absolute;
			right: 20rpx;
			top: 20rpx;

		}
	}

	.box-1 {
		width: 100%;
		height: auto;
		box-sizing: content-box;
		/* 兼容iPhoneX */
		margin-bottom: 0;
		margin-bottom: constant(safe-area-inset-bottom);
		margin-bottom: env(safe-area-inset-bottom);
	}

	.voice-bar {
		width: 300rpx;
		height: 200rpx;
		background-color: #5FBC94;
		position: fixed;
		left: 0;
		right: 0;
		top: 33%;
		margin: auto;
		z-index: 99;
		border-radius: 20rpx;
		display: flex;
		align-items: center;
		justify-content: center;

		.time {
			margin-left: 10rpx;
		}
	}

	.voice_an {
		width: 300rpx;
		height: 300rpx;
		position: fixed;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -55%);
		background-color: rgba(41, 41, 41, 0.7);
		color: white;
		display: flex;
		flex-direction: column;
		align-items: center;
		text-align: center;
		border-radius: 10rpx;

		.text {
			padding-top: 30rpx;
		}

		@keyframes runVoice {
			0% {
				height: 10%;
			}

			20% {
				height: 50%;
			}

			50% {
				height: 100%;
			}

			80% {
				height: 50%;
			}

			100% {
				height: 0%;
			}
		}

		.wave {
			width: 6rpx;
			height: 100%;
			margin-left: 10rpx;
			border-radius: 50rpx;
			background-color: #999;
			vertical-align: middle;
			display: inline-block;
		}

		.voice_an_icon {
			width: 200rpx;
			height: 100rpx;
			line-height: 50rpx;
			margin: 50rpx 0;
		}

		.voice_an_icon #one {
			animation: runVoice 0.6s infinite 0.1s;
		}

		.voice_an_icon #two {
			animation: runVoice 0.6s infinite 0.3s;
		}

		.voice_an_icon #three {
			animation: runVoice 0.6s infinite 0.6s;
		}

		.voice_an_icon #four {
			animation: runVoice 0.6s infinite 0.1s;
		}

		.voice_an_icon #five {
			animation: runVoice 0.6s infinite 0.3s;
		}

		.voice_an_icon #six {
			animation: runVoice 0.6s infinite 0.6s;
		}

		.voice_an_icon #seven {
			animation: runVoice 0.6s infinite 0.1s;
		}
	}

	.box-2 {
		position: fixed;
		left: 0;
		width: 100%;
		bottom: 0;
		height: auto;
		z-index: 99;
		box-sizing: content-box;
		background-color: #1D2123;
		/* 兼容iPhoneX */
		padding-bottom: 0;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);

		.img-box {
			height: 400rpx;
			padding: 30rpx;
			border-top: 2px solid #dedede;
			display: flex;

			.img-item {
				width: 20%;
				text-align: center;
				color: #fff;

				.icon {
					display: flex;
					justify-content: center;
				}
			}
		}

		.emoji-div {
			height: 400rpx;
			padding: 20rpx;
			border-top: 2px solid #dedede;
			flex-wrap: wrap;
			overflow-y: scroll;
			display: flex;
			align-items: center;

			.emoji-item {
				width: 12.5%;
				height: 40rpx;
				margin-bottom: 20px;
				font-size: 50rpx;
				text-align: center;
			}
		}

		.fun-btn {
			width: 100%;
			display: flex;
			align-items: center;
			padding: 20rpx 30rpx;
			justify-content: space-between;

			.btn-right {
				display: flex;
				align-items: center;
				justify-content: space-between;

				image {
					width: 42.03rpx;
					height: 42.03rpx;
					margin-left: 20rpx;
				}

				.send {
					margin-left: 20rpx;
					color: #fff;
					height: 54rpx;
					width: 100rpx;
					line-height: 54rpx;
				}
			}

			.btn-left {
				width: 100%;
				display: flex;
				align-items: center;



				.middbox {
					width: 100%;
					display: flex;
					align-items: center;

					.yuyin {
						margin-right: 20rpx;

						.img1 {
							width: 34rpx;
							height: 42.03rpx;
						}

						.img2 {
							width: 42.03rpx;
							height: 42.03rpx;
						}
					}

					.midd {
						width: 100%;

						.voice_title {
							text-align: center;
							background: linear-gradient(90deg, rgb(200, 246, 115) 0%, rgb(152, 240, 131) 100%);
							height: 80rpx;
							line-height: 80rpx;
							border-radius: 12rpx;
						}
					}
				}
			}
		}
	}

	.talk-list {
		padding-bottom: 20rpx;

		.talk-time {
			text-align: center;
			color: #fff;
			padding: 10rpx 0;
			font-size: 24rpx;
		}

		.withdraw {
			text-align: center;
			color: #fff;
			font-size: 24rpx;
			padding: 30rpx 0;
		}

		.envelopelq {
			text-align: center;
			color: #fff;
			font-size: 24rpx;
			margin-bottom: 20rpx;
		}

		/* 消息项，基础类 */
		.item {
			padding: 20rpx;
			align-items: center;
			align-content: flex-start;
			color: #333;
			position: relative;

			.fun-data1 {
				position: absolute;
				top: -80rpx;
				right: 30rpx;
				background-color: #fff;
				padding: 0 10rpx;
				display: flex;
				border-radius: 10rpx;
				align-items: center;
				justify-content: space-between;
				z-index: 9;

				.fun-item {
					width: 100rpx;
					padding: 20rpx 0;
					justify-content: center;
					display: flex;
					align-items: center;
					font-size: 26rpx;
				}

				&::after {
					content: '';
					display: block;
					width: 0;
					height: 0;
					border-top: 16rpx solid transparent;
					border-bottom: 16rpx solid transparent;
					border-right: 20rpx solid #fff;
					position: absolute;
					bottom: -18rpx;
					z-index: -1;
					/* 调整箭头位置，向上偏移 */
					right: 10rpx;
					/* 调整箭头位置，向左偏移 */
					transform: rotate(-90deg);
					/* 将箭头旋转45度，使其朝向右下角 */
				}
			}

			.fun-data2 {
				position: absolute;
				top: -80rpx;
				left: 30rpx;
				background-color: #fff;
				padding: 0 10rpx;
				display: flex;
				border-radius: 10rpx;
				align-items: center;
				justify-content: space-between;
				z-index: 9;

				.fun-item {
					width: 100rpx;
					padding: 20rpx 0;
					display: flex;
					align-items: center;
					justify-content: center;
					font-size: 24rpx;
				}

				&::after {
					content: '';
					display: block;
					width: 0;
					height: 0;
					border-top: 16rpx solid transparent;
					border-bottom: 16rpx solid transparent;
					border-left: 20rpx solid #fff;
					/* 使用 border-left 替换 border-right */
					position: absolute;
					bottom: -18rpx;
					left: 10rpx;
					z-index: -1;
					/* 调整箭头位置，向左偏移 */
					transform: rotate(90deg);
					/* 将箭头旋转为垂直向上 */
				}
			}

			.pic {
				width: 92rpx;
				height: 92rpx;
				border-radius: 50%;
				border: #fff solid 1px;
			}

			.content {
				padding: 20rpx;
				border-radius: 4px;
				max-width: 500rpx;
				word-break: break-all;
				line-height: 52rpx;
				position: relative;
				display: inline-block;
			}

			.content-hb {
				border-radius: 4px;
				max-width: 500rpx;
				word-break: break-all;
				line-height: 52rpx;
				position: relative;

				.hb-box {
					width: 475.67rpx;
					height: 160rpx;
				}
			}

			.content-vcmsg {
				min-width: 160rpx;
				padding: 20rpx 20rpx 20rpx 30rpx;
				border-radius: 4px;
				word-break: break-all;
				position: relative;
				display: flex;
				flex-direction: row;
				align-items: center;

				.voice_icon {
					height: 34rpx;
					width: 34rpx;
					background-repeat: no-repeat;
					background-size: 100%;
				}

				.voice_icon_right {
					background-image: url(../../../static/chat/voice-left-3.png);
					margin-right: 10rpx;
				}

				.voice_icon_left {
					background-image: url(../../../static/chat/voice-right-3.png);
					margin-right: 20rpx;
				}

				.voice_icon_right_an {
					animation: voiceAn_right 1s linear alternate infinite;
				}

				.voice_icon_left_an {
					animation: voiceAn_left 1s linear alternate infinite;
				}

				.voice_text {
					font-size: 26rpx;
				}

				@keyframes voiceAn_right {
					0% {
						background-image: url(../../../static/chat/voice-left-1.png);
					}

					50% {
						background-image: url(../../../static/chat/voice-left-2.png);
					}

					100% {
						background-image: url(../../../static/chat/voice-left-3.png);
					}
				}

				@keyframes voiceAn_left {
					0% {
						background-image: url(../../../static/chat/voice-right-1.png);
					}

					50% {
						background-image: url(../../../static/chat/voice-right-2.png);
					}

					100% {
						background-image: url(../../../static/chat/voice-right-3.png);
					}
				}
			}

			/* 收到的消息 */
			&.pull {
				.item-name {
					color: #e2e2e2;
					padding-left: 30rpx;
					padding-bottom: 10rpx;
					text-align: left;
					font-size: 26rpx;
				}

				.content-vcmsg {
					margin-left: 32rpx;
					background-color: #232526;
					color: #fff;

					&::after {
						content: '';
						display: block;
						width: 0;
						height: 0;
						border-top: 16rpx solid transparent;
						border-bottom: 16rpx solid transparent;
						border-right: 20rpx solid #232526;
						position: absolute;
						top: 30%;
						left: -18rpx;
					}
				}

				.content-hb {
					margin-left: 32rpx;
					background-color: #232526;
					color: #fff;

					&::after {
						content: '';
						display: block;
						width: 0;
						height: 0;
						border-top: 16rpx solid transparent;
						border-bottom: 16rpx solid transparent;
						border-right: 20rpx solid #e18d35;
						position: absolute;
						top: 40%;
						left: -18rpx;
					}
				}

				.content {
					margin-left: 32rpx;
					background-color: #232526;
					color: #fff;

					&::after {
						content: '';
						display: block;
						width: 0;
						height: 0;
						border-top: 16rpx solid transparent;
						border-bottom: 16rpx solid transparent;
						border-right: 20rpx solid #232526;
						position: absolute;
						top: 40%;
						left: -18rpx;
					}
				}
			}

			/* 发出的消息 */
			&.push {
				/* 主轴为水平方向，起点在右端。使不修改DOM结构，也能改变元素排列顺序 */
				flex-direction: row-reverse;

				.item-name {
					color: #e2e2e2;
					font-size: 26rpx;
					padding-right: 30rpx;
					padding-bottom: 10rpx;
					text-align: right;
				}

				.content-vcmsg {
					margin-right: 32rpx;
					background-color: #232526;
					color: #fff;

					&::after {
						content: '';
						display: block;
						width: 0;
						height: 0;
						border-top: 16rpx solid transparent;
						border-bottom: 16rpx solid transparent;
						border-left: 20rpx solid #232526;
						position: absolute;
						top: 30%;
						right: -18rpx;
					}
				}

				.content-hb {
					margin-right: 32rpx;
					background-color: #232526;
					color: #fff;

					&::after {
						content: '';
						display: block;
						width: 0;
						height: 0;
						border-top: 16rpx solid transparent;
						border-bottom: 16rpx solid transparent;
						border-left: 20rpx solid #e18d35;
						position: absolute;
						top: 40%;
						right: -18rpx;
					}
				}

				.content {
					margin-right: 32rpx;
					background-color: #232526;
					color: #fff;

					&::after {
						content: '';
						display: block;
						width: 0;
						height: 0;
						border-top: 16rpx solid transparent;
						border-bottom: 16rpx solid transparent;
						border-left: 20rpx solid #232526;
						position: absolute;
						top: 40%;
						right: -18rpx;
					}
				}
			}
		}
	}
</style>